package com.allwees.bs.module.mms.req.query;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.allwees.bs.core.modelbase.req.QueryReq;
import com.allwees.bs.module.mms.entity.Store;
import com.allwees.core.common.constant.EStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = true)
public class StoreQueryReq extends QueryReq<Store> {
    private EStoreStatus status;

    private String retailerUuid;

    @Override
    public void buildQuery(QueryWrapper<Store> queryWrapper) {
        queryWrapper
                .eq(StringUtils.isNoneBlank(retailerUuid), "retailer_uuid", retailerUuid)
                .in("status", status.entityStatus());
    }

    private enum EStoreStatus {
        NORMAL {
            @Override
            List<Integer> entityStatus() {
                return Arrays.asList(
                        EStatus.NORMAL.value()
                );
            }
        },
        DISABLED {
            @Override
            List<Integer> entityStatus() {
                return Arrays.asList(
                        EStatus.DISABLED.value()
                );
            }
        };

        abstract List<Integer> entityStatus();
    }
}
